package com.ai.imagetext.service;

import org.springframework.stereotype.Service;

import java.util.Random;

@Service
public class CaptchaService {
    
    private final Random random = new Random();
    
    /**
     * 生成4位随机验证码
     */

    public String generateCaptcha() {
        String chars = "0123456789ABCDEFGHJKLMNPQRSTUVWXYabcdefghijkmnpqrstuvwxyz";
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            sb.append(chars.charAt(random.nextInt(chars.length())));
        }
        return sb.toString();
    }
}